#ifndef MODBUS_RTU_MASTER_H
#define MODBUS_RTU_MASTER_H

#include <QMainWindow>
#include <QModbusRtuSerialMaster>
#include <QSerialPort>

namespace Ui {
class modbus_rtu_master;
}

class modbus_rtu_master : public QMainWindow
{
    Q_OBJECT

public:
    modbus_rtu_master(QWidget *parent = nullptr);
    ~modbus_rtu_master();

private slots:
    void on_connectButton_clicked();
    void on_sendButton_clicked();
    void onReadReady();
    void handleError(QModbusDevice::Error error);

private:
    Ui::modbus_rtu_master *ui;
    QModbusRtuSerialMaster *modbusDevice = nullptr;
    void setupModbusMaster();
    void updateUiState(bool connected);
};

#endif // MODBUS_RTU_MASTER_H